package cn.edu.fzu.delivery.domain.handler;

import cn.edu.fzu.delivery.domain.enums.NetworkApplyStatusEnum;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author yifan
 * @date 2022/11/12
 */
public class NetworkApplyStatusHandler extends BaseTypeHandler<NetworkApplyStatusEnum> {
    @Override
    public void setNonNullParameter(PreparedStatement preparedStatement, int i,
                                    NetworkApplyStatusEnum networkApplyStatusEnum, JdbcType jdbcType)
            throws SQLException {
        preparedStatement.setInt(i, networkApplyStatusEnum.getValue());
    }


    @Override
    public NetworkApplyStatusEnum getNullableResult(ResultSet resultSet, String s) throws SQLException {
        return NetworkApplyStatusEnum.parse(resultSet.getInt(s));
    }


    @Override
    public NetworkApplyStatusEnum getNullableResult(ResultSet resultSet, int i) throws SQLException {
        return NetworkApplyStatusEnum.parse(resultSet.getInt(i));
    }


    @Override
    public NetworkApplyStatusEnum getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
        return NetworkApplyStatusEnum.parse(callableStatement.getInt(i));
    }
}
